package com.jindu.producer.system.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;


/**
 * @author jarvis
 */
@Component
public class MessageSend {


    /************
     * 邮件发送相关
     ************/

    /**
     * 注册邮件提醒模板
     */
    private String emailRegisterTemplate="<!DOCTYPE html>\n" +
            "<html>\n" +
            "<head>\n" +
            "<meta charset=\"utf-8\">\n" +
            "<title>jindu Email</title>\n" +
            "</head>\n" +
            "<body>\n" +
            "<table style=\"margin:30px auto;background-color: #242424;width: 680px;font-size: 14px;color: #828282; line-height: 30px;border-radius: 6px; padding: 30px 0px;\" cellspacing=\"0\" cellpadding=\"0\" >\n" +
            "\t<tbody>\n" +
            "\t \t<tr>\n" +
            "\t \t\t<td colspan=\"3\" align=\"center\" style=\"padding-bottom: 30px\"><img src=\"http://alpha.biz/images/logo_yellow.png\" width=\"200px\" alt=\"jindu\" /></td>\n" +
            "\t \t</tr>\n" +
            "\t \t<tr>\n" +
            "\t \t\t<td width=\"8%\"></td>\n" +
            "\t \t\t<td width=\"82%\" style=\"padding:20px 30px;border:2px solid #ecbe76; font-size: 14px; box-shadow: 0 0 30px #000000;\">\n" +
            "\t \t\t\t<p>\n" +
            "\t\t\t\t<font color=\"#ecbe76\">Hi</font><br> \n" +
            "\t\t\t\t{0}" +
            "\t\t\t\t</p>\n" +
            "\t \t\t</td>\n" +
            "\t \t\t<td width=\"8%\"></td>\n" +
            "\t \t</tr>\n" +
            "\t \t<tr>\n" +
            "\t \t\t<td colspan=\"3\" align=\"center\" >\n" +
            "\t \t\t\t<p style=\"line-height: 20px; padding-top: 30px;font-size: 14px; \">\n" +
            "\t\t\t\t\tjindu Official<br>\n" +
            "\t\t\t\t\t<a href=\"http://alpha.biz\" target=\"_blank\" style=\"color:#ecbe76;\">http://jindu.com</a>\n" +
            "\t\t\t\t</p>\n" +
            "\t \t\t</td>\n" +
            "\t \t</tr>\n" +
            "\t</tbody>\n" +
            "</table>\n" +
            "</body>\n" +
            "</html>";

    @Value("${alphaMessages.email.title.register.cn}")
    private String emailRegisterTitleCn;

    @Value("${alphaMessages.email.body.register.cn}")
    private String emailRegisterBodyCn;


    @Value("${alphaMessages.email.title.register.en}")
    private String emailRegisterTitleEn;

    @Value("${alphaMessages.email.body.register.en}")
    private String emailRegisterBodyEn;


    /******
     * 邮件
     *****/

    public String getEmailRegisterTitleCn() {
        return emailRegisterTitleCn;
    }

    public void setEmailRegisterTitleCn(String emailRegisterTitleCn) {
        this.emailRegisterTitleCn = emailRegisterTitleCn;
    }

    //中文邮件正文
    public String getEmailRegisterBodyCn(String code) {
        String body= MessageFormat.format(emailRegisterBodyCn,code);
        return MessageFormat.format(emailRegisterTemplate,body);
    }

    public void setEmailRegisterBodyCn(String emailRegisterBodyCn) {
        this.emailRegisterBodyCn = emailRegisterBodyCn;
    }


    public String getEmailRegisterTitleEn() {
        return emailRegisterTitleEn;
    }

    public void setEmailRegisterTitleEn(String emailRegisterTitleEn) {
        this.emailRegisterTitleEn = emailRegisterTitleEn;
    }

    //英文邮件正文
    public String getEmailRegisterBodyEn(String code) {
        String body= MessageFormat.format(emailRegisterBodyEn,code);
        return MessageFormat.format(emailRegisterTemplate,body);
    }

    public void setEmailRegisterBodyEn(String emailRegisterBodyEn) {
        this.emailRegisterBodyEn = emailRegisterBodyEn;
    }
}
